﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wpf.CommonTools.DateTimeExtension
{
    /// <summary>
    /// 
    /// </summary>
    public static class DateTimeExtension
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="defaultDate"></param>
        /// <returns></returns>
        public static DateTime ToDateTime(this string input, DateTime defaultDate)
        {
            DateTime dt;
            bool b = DateTime.TryParse(input, out dt);
            if (b)
            {
                return dt;
            }
            else
            {
                return defaultDate;
            }
        }
    }
}
